home *** CD-ROM | disk | FTP | other *** search
/ Video Toaster 4.2 / Video Toaster v4.2.iso / arexx / modeler / explode.lwm < prev    next >
Text File  |  1993-12-13  |  2KB  |  105 lines

  1. /* CMD: Explode Points
  2.  * Transform points algorithmically: Explode from center
  3.  * By Arnie Cachelin © 1993 NewTek Inc.
  4.  */
  5.  
  6. libadd = addlib("LWModelerARexx.port",0)
  7. signal on error
  8. signal on syntax
  9.  
  10. call addlib "rexxsupport.library", 0, -30, 0
  11. MATHLIB="rexxmathlib.library"
  12. IF POS(MATHLIB , SHOW('L')) = 0 THEN
  13.   IF ~ADDLIB(MATHLIB , 0 , -30 , 0) THEN DO
  14.     call notify(1,"!Can't find "MATHLIB)
  15.     exit
  16.     END
  17.  
  18. type=1
  19. rate=90
  20. rmax=1
  21. cx=0
  22. cy=0
  23. cz=0
  24. version = 'Explode v1.0'
  25. filnam = 'ENV:Explode.state'
  26. if (exists(filnam)) then do
  27.     if (~open(state, filnam, 'R')) then break
  28.     if (readln(state) ~= version) then break
  29.     parse value readln(state) with rate cx cy cz rmax type .
  30.     call close state
  31. end
  32.  
  33. call req_begin "Explode Points"
  34.  
  35. id_txt = req_addcontrol("Scale radial position", 'T',"of points inside Effect Radius")
  36. id_txt = req_addcontrol("by Explosion Amount %", 'T',"")
  37. id_type = req_addcontrol("", 'CH','Explode Implode')
  38. id_cen = req_addcontrol("Center", 'v', 1)
  39. id_rate = req_addcontrol("Explosion Amount (%)", 'n', 0)
  40. id_rad = req_addcontrol("Effect Radius", 'n', 0)
  41.  
  42. call req_setval id_type, type
  43. call req_setval id_rate, rate
  44. call req_setval id_cen, cx cy cz, 0.0
  45. call req_setval id_rad, rmax, 1.0
  46.  
  47. if (~req_post()) then do
  48.   call req_end
  49.   req=0
  50.   exit
  51.   end
  52.  
  53. rate=req_getval(id_rate)
  54. parse value req_getval(id_cen) with cx cy cz .
  55. rmax =req_getval(id_rad)
  56. type =req_getval(id_type)
  57. xform.1=(rate+100)/100
  58. xform.2=abs(rate-100)/100
  59.  
  60. call req_end
  61.  
  62. if (open(state, filnam, 'W')) then do
  63.     call writeln state, version
  64.     call writeln state, rate cx cy cz rmax type
  65.     call close state
  66. end
  67.  
  68. Pi=3.14159265358
  69. DegreesPerRadian= 180/pi
  70.  
  71. /* Transform loop
  72.  */
  73. t=time('e')
  74. n = xfrm_begin()
  75. call meter_begin n+2 , "Exploding "n" Points," ,"     Be right with you."
  76. do i = 1 to n
  77.   parse value xfrm_getpos(i) with x y z .
  78.   dx = x - cx
  79.   dy = y - cy
  80.   dz = z - cz
  81.   r = sqrt(dx * dx + dy * dy + dz * dz)
  82.   if (r ~= 0 & r<=rmax) then do
  83.       x = cx + dx *  xform.type
  84.     y = cy + dy *  xform.type
  85.       z = cz + dz *  xform.type
  86.     call xfrm_setpos i, x y z
  87.     end
  88.   call meter_step
  89.   end
  90. call meter_end
  91. call xfrm_end
  92. t=time('e')-t
  93. say 'Whew, I just transformed 'n' points in only 't' seconds.'
  94. call notify(1,'!Whew, I just transformed 'n' points','!in only 't' seconds.')
  95. if (libadd) then call remlib("LWModelerARexx.port")
  96. exit
  97.  
  98. syntax:
  99. error:
  100.   call end_all
  101.     t=Notify(1,'!Rexx Script Error','@'ErrorText(rc),'Line 'SIGL)
  102.   if (libadd) then call remlib("LWModelerARexx.port")
  103.     exit
  104.  
  105.